/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package EvoAlg;

/**
 *
 * @author Geost1gma
 */
public class Population {
    private int popsize;  
    private Individual pop[]; 
    private int numberOfGenotypes;

    public Population(int popsize) {
        this.popsize = popsize;
        pop = new Individual[popsize];
        this.numberOfGenotypes = numberOfGenotypes;

        
        for (int i = 0; i < popsize; i++) {
            pop[i] = new Individual();
        }


    }
    public Individual getIndividualAtIndex(int index){
        return pop[index];
    }
    public void replaceWorst(Individual replacer){
        int worst = -1;
        int tempvalue = 1;
        for (int i = 0; i < pop.length; i++) {
           if(pop[i].getFitness()< tempvalue) worst = i;

        }

        pop[worst] = replacer;
    }

    public int getNumberOfGenotypes() {
        return numberOfGenotypes;
    }

    public void setNumberOfGenotypes(int numberOfGenotypes) {
        this.numberOfGenotypes = numberOfGenotypes;
    }

    public Individual[] getPop() {
        return pop;
    }

    public void setPop(Individual[] pop) {
        this.pop = pop;
    }

    public int getPopsize() {
        return popsize;
    }

    public void setPopsize(int popsize) {
        this.popsize = popsize;
    }
    public void setIndividual(int index, Individual in){
        pop[index] = in;
    }
    
}
